#ifndef _DAC_H
#define _DAC_H
#include "sn_config.h"

#define DAC_MAX_1V2  0
#define DAC_MAX_3V3  1
#define DAC_MAX_4V0  2

struct dac_factor_t
{
    uint16_t k_val      ;//设定值
    uint16_t u_vout     ;//设定电压值
    uint16_t v_default  ;//默认输出值
};
struct dac_dev_t
{
    uint8_t max ;
    uint16_t y_setting;//上位机设定值
    struct dac_factor_t *factor;
    void (*set_out) (struct dac_dev_t*dev);
    void (*change_setting_val) (struct dac_dev_t*dev,uint16_t val);
    uint16_t (*get_setting_val) (struct dac_dev_t *dev);
    /**
     * @brief 设置dac 值
     * 
     * @param val  0~4095 对应0~4.1V
     */
    void (*set_register_val)(uint16_t val);
    /**
     * @ 根据电压值返回对应的dac 值
     */
    uint16_t (*get_vol_val)(struct dac_dev_t*dev,uint16_t vol);
};

int dac_init(struct dac_dev_t **dev);
#endif // !_DAC_H

